<?php
/**
* @property CI_Loader $load
* @property CI_Form_validation $form_validation
* @property CI_Input $input
* @property CI_Email $email
* @property CI_DB_active_record $db
*
*/
class Employee extends CI_Model
{
    function get_DE($code)
    {
        $this->db->select('id');
        $this->db->where('code',$code);
        $this->db->where('rank','DE');
        $query=$this->db->get("employee");
      //  echo $query->num_rows();
        $de=$query->row();
        return $de->id;
    }
    function  login($id,$password,$rank)
    {
        $this->db->select('id');
        $this->db->where('password',$password);
        $this->db->where('rank',$rank);
         $query=$this->db->get("employee");
      //  echo $query->num_rows();
        $de=$query->row();
        if($de->id==$id)
            return true;
        else 
            return false;
        
    }
    function  get_SDE($id)
    {
        $this->db->select('id,name');
        $this->db->where('worksunder',$id);
        $query=$this->db->get("employee");
      //  echo $query->num_rows();
        return $query->result();
    }
    function get_code($id)
    {
        $this->db->select('code');
        $this->db->where('id',$id);
        $query=$this->db->get("employee");
        $obj=$query->row();
        return $obj->code;
    }
    function get_sde_status($empid)
    {
         $query=$this->db->query(  "SELECT
                            count(*) as count
                            FROM
                            newhandle
                            Inner Join newconnection ON newhandle.appid = newconnection.appid
                            WHERE
                            newhandle.empid =  '$empid' AND
                            newconnection.`status`=  'Forwarded'");
         $row=$query->row();
         $status['New']=$row->count;
         $query=$this->db->query(  "SELECT
                            count(*) as count
                            FROM
                            shifthandle
                            Inner Join shiftconnection ON shifthandle.appid = shiftconnection.appid
                            WHERE
                            shifthandle.empid =  '$empid' AND
                           shiftconnection.`status`=  'Forwarded'");
         $row=$query->row();
         $status['shift']=$row->count;
         $query=$this->db->query(  "SELECT
                            count(*) as count
                            FROM
                            complainhandle
                            Inner Join complain ON complainhandle.appid = complain.appid
                            WHERE
                            complainhandle.empid =  '$empid' AND
                           complain.`status`=  'Undertaken'");
         $row=$query->row();
         $status['complain']=$row->count;
         return $status;
    }
}


?>
